# $Id$
# $Name$

.SUFFIXES: .e .o .mk
MCCC = c:\mcc18\bin\mcc18.exe
MCCL = c:\mcc18\bin\mplink.exe
INCLUDE = -I"C:\Microchip Solutions\Microchip\Include\Usb" -I"C:\Microchip Solutions\Microchip\Include" -I"C:\MCC18\h"
MCCFLAGS = -p=18F4550 -D__DEBUG -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
OBJS = chunk_buffer.o cyclic_buffer.o user.o 
MOBJS += $(OBJS) main.o usb_device.o usb_descriptors.o

LIBS = /l"c:\mcc18\lib" /k"c:\mcc18\lkr" "rm18f4550.lkr"
LFLAGS = /u_CRUNTIME /u_DEBUG /z__MPLAB_BUILD=1 /z__MPLAB_DEBUG=1 /W

DEPENDENCIES = $(OBJS:.o=.h) $(MOBJS:.o=.c)

chunk_buffer.o:	chunk_buffer.c chunk_buffer.h types.h
	@echo "MCCC $<"
	@$(MCCC) $(MCCFLAGS) $(INCLUDE) $< -fo=$@
	
cyclic_buffer.o:	cyclic_buffer.c cyclic_buffer.h
	@echo "MCCC $<"
	@$(MCCC) $(MCCFLAGS) $(INCLUDE) $< -fo=$@
	
user.o:	user.c user.h chunk_buffer.h
	@echo "MCCC $<"
	@$(MCCC) $(MCCFLAGS) $(INCLUDE) $< -fo=$@
	
usb_device.o:	usb_device.c HardwareProfile.h
	@echo "MCCC $<"
	@$(MCCC) $(MCCFLAGS) $(INCLUDE) $< -fo=$@
	
usb_descriptors.o:	usb_descriptors.c
	@echo "MCCC $<"
	@$(MCCC) $(MCCFLAGS) $(INCLUDE) $< -fo=$@
	
main.o:	main.c user.c user.h chunk_buffer.h cyclic_buffer.h
	@echo "MCCC $<"
	@$(MCCC) $(MCCFLAGS) $(INCLUDE) $< -fo=$@
	
#.c.mk:
#	@echo "CC [M]	$<"
	
#.c.o:
#$(DEPENDENCIES)
#	@echo "MCCC	$<"
#	@echo $(DEPENDENCIES)
#	@$(MCCC) $(MCCFLAGS) $(INCLUDE) $< -fo=$@

#$(MOBJS):	$(DEPENDENCIES)
#	@$(MCCC) $(MCCFLAGS) $(INCLUDE) $< -fo=$@

usbfw:	$(MOBJS)
	@echo "LD	$<"
	@echo $(MOBJS)
	@$(MCCL) $(LIBS) $(MOBJS) $(LFLAGS) /o$@.cof /M"usb_logger.map"

#chunk_buffer.o:		chunk_buffer.c
#	C:\MCC18\bin\mcc18.exe $(MCCFLAGS) $(INCLUDE) $< -fo=$@


#"C:\MCC18\bin\mplink.exe" /l"C:\MCC18\lib" /k"C:\MCC18\lkr" "rm18f4550 - MCHPUSB Bootload.lkr" "chunk_buffer.o" "cyclic_buffer.o" "main.o" "usb_descriptors.o" "user.o" "usb_device.o" /u_CRUNTIME /u_DEBUG /z__MPLAB_BUILD=1 /z__MPLAB_DEBUG=1 /o"usb_logger.cof" /M"usb_logger.map" /W
